<include file="Common:layout" />
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>商品管理 - 会员价</h3>
                <h5>不同的会员级别设置不同价格</h5>
            </div>
        </div>
    </div>


    <!-- 操作说明 -->
    <div class="explanation">
        <div class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">{$g_name}</h4>
        </div>
    </div>

    <form action="{:U('Good/price')}" method="post" class="form-horizontal" id="category_form">
        <input name="id" type="hidden" value="{$id}">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label>价格阶梯</label>
                </dt>
                <dd class="opt">
                    <notempty name="good_rank_price">
                        <volist name="good_rank_price" id="price">
                            <div class="alisth0" style="margin-bottom:10px;">
                                <b style="color:#3aa8cf;">{$price['rank_name']}</b> 单件拿货价：
                                <input type="text" class="amt_i_1" value="{$price['unit_amt']}" name="unit_amt[{$price['rank_id']}]" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" style="width:100px;">&nbsp;
                                <b style="color:#3aa8cf;">{$price['rank_name']}</b> 整箱拿货价：
                                <input type="text" class="amt_i_2" value="{$price['batch_amt']}" name="batch_amt[{$price['rank_id']}]" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" style="width: 100px;">
                            </div>
                        </volist><else />
                        <volist name="agent_rank" id="rank" key="k">
                            <div class="alisth0" style="margin-bottom:10px;">
                                <b style="color:#3aa8cf;">{$rank['rank_name']}</b> 单件拿货价：
                                <input type="text" class="amt_i_1" name="unit_amt[{$rank['rank_id']}]"  onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" style="width:100px;">&nbsp;
                                <b style="color:#3aa8cf;">{$rank['rank_name']}</b> 整箱拿货价：
                                <input type="text" class="amt_i_2" name="batch_amt[{$rank['rank_id']}]" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" style="width: 100px;">
                            </div>
                        </volist>
                    </notempty>
                </dd>
            </dl>
            <div class="bot">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>

    </form>
</div>
<script>
    $(function() {
        //提交
        $("#submitBtn").click(function(){
            //$price_len = $(".amt_i").length;
            $price_len = $('input').length;
            for($i = 0;$i < $price_len;$i ++){
                if($("input").eq($i).val() == ""){
                    layer.alert("请填写完整价格！");return false;
                }
            }
            $("#category_form").submit();
        });

        //会员价格要越来越大
        $('.amt_i_1,.amt_i_2').blur(function() {
            var _class = '.'+$(this).attr('class');
            var now_price = $(this).val();
            var prev_price = $(this).parent().prev().find(_class).val();
            var next_price = $(this).parent().next().find(_class).val();

            if (typeof(prev_price) != 'undefined') {
                if (now_price <= prev_price) {
                    layer.msg('当前价格必须比上面的高!');
                    $(this).focus();
                }
            }
            if (next_price != '' && now_price >= next_price) {
                layer.msg('当前价格必须比下面的低!');
                $(this).focus();
            }

        });




    });
</script>
</body>
</html>